﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using System.Data.Linq;
using System.Linq;
using System.Runtime.InteropServices;
using QuanLyThuVien.BUS;


namespace QuanLyThuVien
{
    public partial class frmTimKiemSach : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        public frmTimKiemSach()
        {
            InitializeComponent();
        }



        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            if (tbtensach.Text == "" && tbtacgia.Text == "" && tbtheloai.Text == "" && tbnhaxuatban.Text == "")
            {
                MessageBox.Show("Chưa điền thông tin cần tìm kiếm");
                return;
            }

            DataTable dt = new DataTable();
            dt = SachBUS.Tim_Kiem_Sach(tbtensach.Text, tbtacgia.Text, tbtheloai.Text, tbnhaxuatban.Text);

            if (dt.Rows.Count < 0 || dt.Rows.Count == 0)
            {
                MessageBox.Show("Cuốn sách bạn tìm không có trong thư viện. Vui lòng tìm cuốn sách khác . Cảm ơn.");
            }
            else
            {
                dgdanhsachsach.DataSource = dt;
            }
         

         
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            tbnhaxuatban.Text = "";
            tbtacgia.Text = "";
            tbtensach.Text = "";
            tbtheloai.Text = "";
            dgdanhsachsach.DataSource = null;
            dgdanhsachsach.Refresh();
           
        }

        private void lblDangNhap_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            frmDangnhap frm = new frmDangnhap();
            frm.Show();
        }

        private void btnthoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void frmTimKiemSach_Load(object sender, EventArgs e)
        {
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
        }

    

    }
}